/* boolean.c -- 布尔类型 */

#include <stdio.h>

int main(void)
{
  long num;
  long sum = 0L;
  _Bool input_is_good;

  printf("Please enter an integer to be summed");
  printf("(enter 'q' to quit): ");
  input_is_good = (scanf("%ld", &num) == 1); // 条件表达式的返回值是真或假，此处外层小括号只是为了增加代码可读性

  while (input_is_good) // 当输入q时，scanf读取到的不是 "%ld"，此时scanf返回0
  {
    sum += num;
    printf("Please enter next integer: ");
    input_is_good = scanf("%ld", &num);
  }
  
  printf("The sum is %ld", sum);  

  return 0;
}